import httpUtil from "@/utils/httpUtil";

const sendLoginSms = (mobile, callBack, errCallBack) => {
	send(mobile, 'mobilelogin', 2, callBack, errCallBack)
}

const sendPaySms = (mobile, callBack, errCallBack) => {
	send(mobile, 'pay', null, callBack, errCallBack)
}

const send = (mobile, event, type, callBack, errCallBack) => {
	let params = {
		mobile,
		event, // 登录mobilelogin，付款pay
	}
	if (type) {
		params.type = type // 产品类型：1=默认,2=黑金卡
	}
	httpUtil.post('/api/rf/sendSms', params, res => {
		if (callBack) {
			callBack(res)
		}
	}, err => {
		if (errCallBack) {
			errCallBack(res)
		}
	})
}

export default {
	sendLoginSms,
	sendPaySms
}